CA_PY,O_PY=1625408,1295128
function geta(add) return gg.getValues({{address=add,flags=32}})[1].value end function getv(add,fla) if fla==nil then fla=4 end return gg.getValues({{address=add,flags=fla}})[1].value end function setv(add,v,f) if f==nil then f=4 end gg.setValues({{address=add,value=v,flags=f}}) end function addv(add,f) if f==nil then f=4 end gg.addListItems({{address=add,flags=f}}) end function jzdw(tt) cs=gg.getRangesList('libGameCore.so:bss')[1]['start'] for i=1,#tt do cs=geta(cs+tt[i]) end return cs end function tzz(tt) cs=0 for i=1,#tt do cs=geta(cs+tt[i]) end return cs end
JN_JZ=jzdw({O_PY,76*8,0x30})
JN_SL=getv(JN_JZ+0x18)
JN_PY=getv(JN_JZ+0x14)
Tab_1,Tab_LM1,Tab_LM2,Tab_JN={},{},{},{}
for i=0,JN_SL-1 do
table.insert(Tab_1, {address=JN_JZ+0X98+i*JN_PY,flags=4})
table.insert(Tab_LM1, {address=JN_JZ+0X98+i*JN_PY+0xc0,flags=4})
table.insert(Tab_LM2, {address=JN_JZ+0X98+i*JN_PY+0xc4,flags=4})
end
Tab_LM1,Tab_LM2=gg.getValues(Tab_LM1),gg.getValues(Tab_LM2)
for i, v in pairs(gg.getValues(Tab_1)) do
Tab_JN[v.value]={Tab_LM1[i]['value'],Tab_LM2[i]['value']}
end

function OJX_Str(Tab_OXG)
Sta_Add=gg.getRangesList('libGameCore.so:bss')[1]['start']+O_PY
Sta_Num=getv(Sta_Add+0x1C)
Sen_Add=geta(Sta_Add)
Tab_1,Tab_N,Tab_A,Tab_P={},{},{},{},{}
for i=0,Sta_Num-1 do
table.insert(Tab_1, {address=Sen_Add+i*8,flags=32})
end
for i, v in pairs(gg.getValues(Tab_1)) do
table.insert(Tab_N, {address=v.value+8,flags=4})
table.insert(Tab_A, {address=v.value+0x10,flags=32})
table.insert(Tab_P, {address=v.value+0x30,flags=32})
end
Tab_N,Tab_A,Tab_P=gg.getValues(Tab_N),gg.getValues(Tab_A),gg.getValues(Tab_P)
Tab_Sta,Tab_Num,Tab_PY={},{},{}
Tab_S={}
for i, v in pairs(Tab_A) do
table.insert(Tab_PY, {address=Tab_P[i]['value']+0x14,flags=4})
table.insert(Tab_Num, {address=Tab_P[i]['value']+0x18,flags=4})
for n=0,Tab_N[i]['value']-1 do
table.insert(Tab_S, {address=v.value+n,flags=1})
end
end
Tab_s,Tab_Num,Tab_PY={},gg.getValues(Tab_Num),gg.getValues(Tab_PY)
for i, v in pairs(gg.getValues(Tab_S)) do
table.insert(Tab_s, v.value)
end
Str=string.char(table.unpack(Tab_s))
Tab_O,Num={},0
for fieldName in Str:gmatch("Databin/(.-)%.bytes") do
Num=Num+1
 Tab_O[fieldName]={Start=Tab_P[Num]['value']+0x98,End=Tab_P[Num]['value']+0x98+Tab_PY[Num]['value']*Tab_Num[Num]['value'],Offset=Tab_PY[Num]['value'],Number=Tab_Num[Num]['value']}
end
--print(Tab_O)
function ODW2(V,sta,py,num)
if Tab_OW==nil then Tab_OW={} end
if Tab_OW[sta]==nil then
Tab_OW[sta]={}
for n=0,num-1 do
table.insert(Tab_OW[sta], {address=py*n+sta,flags=4})
end
Tab_OW[sta]=gg.getValues(Tab_OW[sta])
end
for i, v in pairs(Tab_OW[sta]) do
if V==v.value then
return v.address
end
end
end
Tab_XG={}
for i, v in pairs(Tab_OXG) do
for m, t in pairs(v) do
for n, T in pairs(t) do
table.insert(Tab_XG,{address=ODW2(m,Tab_O[i]['Start'],Tab_O[i]['Offset'],Tab_O[i]['Number'])+T['d'],flags=T['f'],value=T['v']})
end
end
end
gg.setValues(Tab_XG)
gg.addListItems(Tab_XG)
gg.alert('>>成功修改'..#Tab_XG..'个数值')
end
function CAJX(CA_Tab) CAJZ=jzdw({CA_PY,0x4D8}) SL=getv(jzdw({CA_PY})+0x4d8+0x1c) Tab_1,Tab_2,Tab_3,Tab_4,Tab_5,Tab_6,Tab_CA={},{},{},{},{},{},{} for i=0,SL-1 do table.insert(Tab_1, {address=CAJZ+i*0x18,flags=32}) end for a,b in pairs(gg.getValues(Tab_1)) do for i=0,400 do table.insert(Tab_2, {address=b.value+0x10+i*0x34,flags=32}) end end for a,b in pairs(gg.getValues(Tab_2)) do  table.insert(Tab_3, {address=b.value+0x10,flags=32})  end for a,b in pairs(gg.getValues(Tab_3)) do table.insert(Tab_4, {address=b.value+0x10,flags=4}) table.insert(Tab_5, {address=b.value+0x14,flags=4}) table.insert(Tab_6, {address=b.value+0x20,flags=32}) end Tab_4,Tab_5,Tab_6=gg.getValues(Tab_4),gg.getValues(Tab_5),gg.getValues(Tab_6) local Tab_T={} for a,b in pairs(Tab_6) do if Tab_CA[Tab_4[a].value..';'..Tab_5[a].value]==nil then Tab_CA[Tab_4[a].value..';'..Tab_5[a].value]=b.value Tab_T[Tab_4[a].value..';'..Tab_5[a].value]=b.address end end local Tab_8={} for i1,v1 in pairs(CA_Tab) do for i2,v2 in pairs(v1) do for i3,v3 in pairs(v2) do for i4,v4 in pairs(v3) do for a,b in pairs(Tab_CA) do if i1==a then table.insert(Tab_8, {address=tzz({b+(i2-1)*8,0x28,0})+v4['d'],flags=v4['f'],value=v4['v'],freeze=false}) break end end end end end end if #Tab_8>0 then gg.setValues(Tab_8 )  gg.addListItems(Tab_8)gg.alert('成功修改'..#Tab_8..'个值') end end 
function QJX(M)
CA_OLD = jzdw({CA_PY})+0x4D8
CAJZ=geta(CA_OLD)
CA_SL=getv(CA_OLD+0x1C)
LM_TZ=getv(jzdw({CA_PY,0x4D8,0,0x10,0x10}))
Tab_1,Tab_2,Tab_3,Tab_4,Tab_5,Tab_6,Tab_7,Tab_8,Tab_9,Tab_CA={},{},{},{},{},{},{},{},{},{}
for i=0,CA_SL-1 do
    table.insert(Tab_1, {address=CAJZ+i*0x18,flags=32})
end
for i, v in pairs(gg.getValues(Tab_1)) do
for i_=0,400 do
table.insert(Tab_2, {address=v.value+i_*0x34,flags=4})
table.insert(Tab_3, {address=v.value+i_*0x34+4,flags=4})
table.insert(Tab_4, {address=v.value+i_*0x34+0x10,flags=32})
end
end
Tab_2,Tab_3,Tab_4=gg.getValues(Tab_2),gg.getValues(Tab_3),gg.getValues(Tab_4)
for i, v in pairs(Tab_4) do
table.insert(Tab_5, {address=v.value+0x10,flags=32})
end
for i, v in pairs(gg.getValues(Tab_5)) do
table.insert(Tab_9, {address=v.value,flags=4})
table.insert(Tab_6, {address=v.value+0x10,flags=4})
table.insert(Tab_7, {address=v.value+0x14,flags=4})
table.insert(Tab_8, {address=v.value+0x20,flags=32})
end
Tab_6,Tab_7,Tab_8=gg.getValues(Tab_6),gg.getValues(Tab_7),gg.getValues(Tab_8)
for i,v in pairs(gg.getValues(Tab_9)) do
if v.value==LM_TZ then
--Tab_CA[Tab_2[i]['value']..';'..Tab_3[i]['value']]=Tab_8[i]['address']
Tab_CA[Tab_6[i]['value']..';'..Tab_7[i]['value']]=Tab_8[i]['address']
end
end
for i , v in pairs(M) do
if Tab_CA[v.DZ] and Tab_CA[v.XGDZ] then
xgsz=tzz({Tab_CA[v.XGDZ],8*(v.XGCS-1),0x28,0})
setv(tzz({Tab_CA[v.DZ],8*(v.DZCS-1),0x28}),xgsz,32)
end
end
end



function QX_WJ() if io.open("/sdcard/chucun.txt", "r")==nil then fi='/sdcard/'else fi=tostring(io.open("/sdcard/chucun.txt", "r"):read("*a"))if fi==nil or fi=="" then fi='/sdcard/'end end f=gg.prompt({"文件路径"},{[1]=fi},{"file"})if f then f=f[1]file=io.open("/sdcard/chucun.txt", "w")file:write(f)io.close(file)xg=nil local file=io.open(f, "r")local Table=file:read("*a")file:close()local TAB=load("return "..Table)()if TAB then for i,v in pairs(TAB) do if i=='O'then OJX(v)elseif i=='Ca'then CAJX(v)elseif i=='O2'then OJX_Str(v)elseif i=='T'then TJX(v)elseif i=='TZ'then ZZJX(v,TAB['XG'])elseif i=='Q'then QJX(v)end end end end end
function SC_WJ()
    local set = gg.prompt({"输入保存文件名称"}, {os.date("%Y%m%d%H%M%S")}, {"text"})
Sta_Add=gg.getRangesList('libGameCore.so:bss')[1]['start']+O_PY
Sta_Num=getv(Sta_Add+0x1C)
Sen_Add=geta(Sta_Add)
Tab_1,Tab_N,Tab_A,Tab_P={},{},{},{},{}
for i=0,Sta_Num-1 do
table.insert(Tab_1, {address=Sen_Add+i*8,flags=32})
end
for i, v in pairs(gg.getValues(Tab_1)) do
table.insert(Tab_N, {address=v.value+8,flags=4})
table.insert(Tab_A, {address=v.value+0x10,flags=32})
table.insert(Tab_P, {address=v.value+0x30,flags=32})
end
Tab_N,Tab_A,Tab_P=gg.getValues(Tab_N),gg.getValues(Tab_A),gg.getValues(Tab_P)
Tab_Sta,Tab_Num,Tab_PY={},{},{}
Tab_S={}
for i, v in pairs(Tab_A) do
table.insert(Tab_PY, {address=Tab_P[i]['value']+0x14,flags=4})
table.insert(Tab_Num, {address=Tab_P[i]['value']+0x18,flags=4})
for n=0,Tab_N[i]['value']-1 do
table.insert(Tab_S, {address=v.value+n,flags=1})
end
end
Tab_s,Tab_Num,Tab_PY={},gg.getValues(Tab_Num),gg.getValues(Tab_PY)
for i, v in pairs(gg.getValues(Tab_S)) do
table.insert(Tab_s, v.value)
end
Str=string.char(table.unpack(Tab_s))
Tab_O,Num={},0
for fieldName in Str:gmatch("Databin/(.-)%.bytes") do
Num=Num+1
 Tab_O[fieldName]={Start=Tab_P[Num]['value']+0x98,End=Tab_P[Num]['value']+0x98+Tab_PY[Num]['value']*Tab_Num[Num]['value'],Offset=Tab_PY[Num]['value'],Number=Tab_Num[Num]['value']}
end
function ODW(V,sta,py,num)
if Tab_OW[sta]==nil then
Tab_OW[sta]={}
for n=0,num-1 do
table.insert(Tab_OW[sta], {address=py*n+sta,flags=4})
end
Tab_OW[sta]=gg.getValues(Tab_OW[sta])
end
for i, v in pairs(Tab_OW[sta]) do
if V>=v.address and V<Tab_OW[sta][i+1]['address'] then
return v.address
end
end
end
Tab_OW,Tab_OXG={},{}
List=gg.getListItems()
O_Num=0
for i, v in pairs(List) do
for n, m in pairs(Tab_O) do
if v.address>=m.Start and v.address<=m.End then
JX_ADD=ODW(v.address,m.Start,m.Offset,m.Number)
if Tab_OXG[n]==nil then Tab_OXG[n]={} end
if Tab_OXG[n][getv(JX_ADD)]==nil then Tab_OXG[n][getv(JX_ADD)]={} end
table.insert(Tab_OXG[n][getv(JX_ADD)], {d=v.address-ODW(v.address,m.Start,m.Offset,m.Number),f=v.flags,v=v.value})
O_Num=O_Num+1
end
end
end

    --0x19A100 -> 0x3A0 -> 0x68 -> 0x10
 List=gg.getListItems()
CA_OLD = jzdw({CA_PY})+0x4D8
CAJZ=geta(CA_OLD)
CA_SL=getv(CA_OLD+0x1C)
LM_TZ=getv(jzdw({CA_PY,0x4D8,0,0x10,0x10}))
Tab_1,Tab_2,Tab_3,Tab_4,Tab_5,Tab_6,Tab_7,Tab_8,Tab_9,Tab_CA={},{},{},{},{},{},{},{},{},{}
for i=0,CA_SL-1 do
    table.insert(Tab_1, {address=CAJZ+i*0x18,flags=32})
end
for i, v in pairs(gg.getValues(Tab_1)) do
for i_=0,400 do
table.insert(Tab_2, {address=v.value+i_*0x34,flags=4})
table.insert(Tab_3, {address=v.value+i_*0x34+4,flags=4})
table.insert(Tab_4, {address=v.value+i_*0x34+0x10,flags=32})
end
end
Tab_2,Tab_3,Tab_4=gg.getValues(Tab_2),gg.getValues(Tab_3),gg.getValues(Tab_4)
for i, v in pairs(Tab_4) do
table.insert(Tab_5, {address=v.value+0x10,flags=32})
end
for i, v in pairs(gg.getValues(Tab_5)) do
table.insert(Tab_9, {address=v.value,flags=4})
table.insert(Tab_6, {address=v.value+0x10,flags=4})
table.insert(Tab_7, {address=v.value+0x14,flags=4})
table.insert(Tab_8, {address=v.value+0x20,flags=32})
end
Tab_6,Tab_7,Tab_8=gg.getValues(Tab_6),gg.getValues(Tab_7),gg.getValues(Tab_8)
for i,v in pairs(gg.getValues(Tab_9)) do
if v.value==LM_TZ then
--Tab_CA[Tab_2[i]['value']..';'..Tab_3[i]['value']]=Tab_8[i]['address']
Tab_CA[Tab_6[i]['value']..';'..Tab_7[i]['value']]=Tab_8[i]['address']
end
end
    Tab_1,Tab_2={},{}
    for i , v in pairs(Tab_CA) do
        Tab_1[#Tab_1+1]={address=v,flags=32}
        Tab_2[#Tab_2+1]={address=v+0x1c,flags=4}        
    end
        Tab_1,Tab_2=gg.getValues(Tab_1),gg.getValues(Tab_2)
 --       gg.addListItems(Tab_2)
        Tab_3,Tab_4,Tab_5={},{},{}
    for i , v in pairs(Tab_1) do
        for i_=0,Tab_2[i]['value']-1 do
            Tab_3[#Tab_3+1]={address=v.value+i_*8,flags=32}
       end
    end
    
    function Tab_PY(Tab_SR,PY,FL)
    local Tab_SC={}
    for i , v in pairs(Tab_SR) do
    Tab_SC[i]={address=v.value+PY,flags=FL}
    end
    return gg.getValues(Tab_SC)
    end
    Tab_5=Tab_PY(Tab_PY(gg.getValues(Tab_3),0x28,32),0,32)
    Tab_3,Tab_6=Tab_PY(Tab_5,0,4),Tab_PY(Tab_5,0x40,32)
--    gg.addListItems(Tab_6)
    s,ss=0,0
    for i , v in pairs(Tab_CA) do
        Tab_4[i]={}
        ss=ss+1
        for i_=0,Tab_2[ss]['value']-1 do
        s=s+1
            table.insert(Tab_4[i],{start=Tab_3[s]['address'],ending=Tab_6[s]['value'],address=Tab_5[s]['address'],cs=i_+1})
       end
    end
    CA_JG,Q_JG={},{}
    function PD(TAB)
    if TAB==nil then return {} else return TAB end
    end 
    for j , k in pairs(Tab_4) do
    for i , v in pairs(k) do
        for i_ , v_ in pairs(List) do
            if v_.address>=v.start and v_.address<=v.ending and v.ending~=0 then
                CA_JG[j]=PD(CA_JG[j])
                CA_JG[j][i]=PD(CA_JG[j][i])
                CA_JG[j][i][1]=PD(CA_JG[j][i][1])
                table.insert(CA_JG[j][i][1], {d=v_.address-v.start,f=v_.flags,v=v_.value})
            end
            if v_.address==v.address then
            XGCSDZ=tzz({v.address,0x10})+0x54
            XGSZDZ=tzz({XGCSDZ-12})            
                Q_JG[#Q_JG+1]={DZ=j,DZCS=v.cs,XGDZ=getv(XGSZDZ+0x10)..';'..getv(XGSZDZ+0X14),XGCS=getv(XGCSDZ,1)+1}
                
            end
        end
    end
    end
   local CC = {}
    if s and s > 0 then
        CC['Ca'] = CA_JG
    end
    if O_Num>0 then
        CC['O2'] = Tab_OXG
    end
    if #Q_JG>0 then
        CC['Q'] = Q_JG
    end
    io.open(set[1] .. '.lua', "w+"):write(tostring(CC)):close()
    B=nil
    Tab_CA=nil
    return gg.alert('生成完毕 >> 已保存至 ' .. set[1] .. '.lua')
end

function GC(Tab)
DB={Ca=CAJX,O2=OJX_Str,Q=QJX}
for i , v in pairs(Tab) do
DB[i](v)
end
end